﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoreHelper.Validation.Validators
{
    class PassValidatorAttribute : BaseValidatorAttribute
    {

        public static PassValidatorAttribute Instance = new PassValidatorAttribute();

        private PassValidatorAttribute(string errorMessage) : base(errorMessage)
        {
        }
        private PassValidatorAttribute() : this(string.Empty) { }
        public override bool IsValid(object value)
        {
            return true;
        }
    }

    public abstract class BaseValidatorAttribute : Attribute
    {
        public BaseValidatorAttribute(string errorMessage)
        {
            ErrorMessage = errorMessage;
        }

        public virtual bool IsValid(object value, ValidationContext validationContext)
        {
            return IsValid(value);
        }
        public virtual bool IsValid(object value)
        {
            return false;
        }


        public string ErrorMessage { get; protected set; }

        public virtual string FormatErrorMessage()
        {
            return ErrorMessage;
        }

        public int Sort { get; protected set; }
    }
}
